import { updateColumn, updateDynamicFormGroup } from '@/api/form'

export default {
  name: 'config',
  props: {
    element: {
      type: Object,
      default() {
        return {}
      }
    },
    attributes: {
      type: Object,
      default() {
        return {}
      }
    },
    type: {
      type: String,
      default: 'input'
    }
  },
  methods: {
    realtimeUpdateElement(element) {
      const target = Object.assign({}, element)
      target.attributes = JSON.stringify(target.attributes)
      updateColumn(target).then(() => {
        this.$message.success('保存成功')
      })
    },
    realtimeUpdateGroup(group) {
      console.log(group)
      updateDynamicFormGroup(group).then(() => {
        this.$message.success('保存成功')
      })
    },
    dynamicOnlineSave() {
      this.realtimeUpdateElement(this.element)
    }
  }
}
